﻿using System;
using UniRx;
using UniRx.Triggers;
using UnityEngine;

namespace Studio
{
	// Token: 0x02000437 RID: 1079
	public class CharAnimeCtrl : MonoBehaviour
	{
		// Token: 0x17000290 RID: 656
		// (get) Token: 0x06001AAF RID: 6831 RVA: 0x000AA784 File Offset: 0x000A8984
		// (set) Token: 0x06001AB0 RID: 6832 RVA: 0x000AA794 File Offset: 0x000A8994
		public bool isForceLoop
		{
			get
			{
				return this.oiCharInfo.isAnimeForceLoop;
			}
			set
			{
				this.oiCharInfo.isAnimeForceLoop = value;
			}
		}

		// Token: 0x17000291 RID: 657
		// (get) Token: 0x06001AB1 RID: 6833 RVA: 0x000AA7A4 File Offset: 0x000A89A4
		// (set) Token: 0x06001AB2 RID: 6834 RVA: 0x000AA7AC File Offset: 0x000A89AC
		public OICharInfo oiCharInfo { get; set; }

		// Token: 0x17000292 RID: 658
		// (get) Token: 0x06001AB3 RID: 6835 RVA: 0x000AA7B8 File Offset: 0x000A89B8
		// (set) Token: 0x06001AB4 RID: 6836 RVA: 0x000AA7C0 File Offset: 0x000A89C0
		public int nameHadh { get; set; }

		// Token: 0x17000293 RID: 659
		// (get) Token: 0x06001AB5 RID: 6837 RVA: 0x000AA7CC File Offset: 0x000A89CC
		public float normalizedTime
		{
			get
			{
				if (this.animator == null)
				{
					return 0f;
				}
				return this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
			}
		}

		// Token: 0x06001AB6 RID: 6838 RVA: 0x000AA804 File Offset: 0x000A8A04
		public void Play(string _name, float _normalizedTime)
		{
			if (this.animator == null)
			{
				return;
			}
			this.animator.Play(_name, 0, _normalizedTime);
		}

		// Token: 0x06001AB7 RID: 6839 RVA: 0x000AA828 File Offset: 0x000A8A28
		private void Awake()
		{
			this.isSync = false;
			(from _ in this.LateUpdateAsObservable()
			where this.animator != null
			where this.isSync
			select this.animator.GetCurrentAnimatorStateInfo(0)).Subscribe(delegate(AnimatorStateInfo info)
			{
				this.animator.Play(info.shortNameHash, 1, info.normalizedTime);
			}).AddTo(this);
			(from _ in this.LateUpdateAsObservable()
			where this.animator != null
			where this.isForceLoop
			select this.animator.GetCurrentAnimatorStateInfo(0) into info
			where !info.loop & info.normalizedTime >= 1f
			select info).Subscribe(delegate(AnimatorStateInfo info)
			{
				this.animator.Play(this.nameHadh, 0, 0f);
			}).AddTo(this);
		}

		// Token: 0x04001D6E RID: 7534
		public Animator animator;

		// Token: 0x04001D6F RID: 7535
		public bool isSync;
	}
}
